<template>
  <a-input-number @change="inputVal" style="width:100%;" v-model:value="value" :min="props.min" :placeholder="props.placeholder" />
</template>
<script setup>
const emits = defineEmits(['update:value'])
const props = defineProps({
  value: Number,
  placeholder: {
    type: String,
    default: '请输入',
  },
  min: {
    type: Number,
    default: '请输入',
  },
})
const state = reactive({
  value: undefined,
})
state.value = props.value

const inputVal = () => {
  emits('update:value', state.value)
}
watch(
  () => props.value,
  (newVal, oldVal) => {
    if (newVal === null || newVal === '' || newVal === undefined) {
      state.value = undefined
    } else {
      state.value = newVal
    }
  },
  { deep: true }
)
defineExpose({})
const { value } = toRefs(state)
</script>

